package com.franklin.ideaplugin.easytesting.utils;

import com.intellij.lang.jvm.JvmParameter;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiParameterList;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author Ye Junhui
 * @since 2023/5/12
 */
public class PsiUtils {

    /**
     * 获取方法的参数
     * @param psiMethod
     * @return
     */
    public static List<PsiParameter> getPsiMethodParameters(@NotNull PsiMethod psiMethod){
        PsiParameterList parameterList = psiMethod.getParameterList();
        return IntStream.range(0,parameterList.getParametersCount())
                .mapToObj(parameterList::getParameter)
                .collect(Collectors.toList());
    }

}
